/**
 * 
 */
package everything.search;
import everything.WorldMap;


public class RTASearch extends ASearch {

	private int _maxExpansions;
	/**
	 * @param state
	 * @param map
	 * @param agent
	 */
	public RTASearch(SearchAgentState state, WorldMap map, SearchAgent agent, int maxExpansions) {
		super(state, map, agent);
		_maxExpansions = maxExpansions;

	}
	
	@Override
	public ASearchNode search() {
		int i = 0;
		while(_goal==null && i < _maxExpansions){
			i++;
			expand();
		}
		_out.close();
		System.out.println("TREE FULLY EXPANDED WITH T="+T);
		if (_goal!= null)
			return _goal;
		else
			return _expansionTree.poll();
	}

}
